//------------------------------------------------------------------------------
// <copyright file="Game.h" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

#pragma once

#include "stdafx.h"
#include <agile.h>
#include "BasicTimer.h"
#include "RpcServer.h"

// A basic game implementation that creates a D3D11 device and
// provides a game loop
ref class Game sealed
{
public:

    Game();

    // Initialization and management
    void Initialize(Windows::UI::Core::CoreWindow^ window);
    void LoadContent();
    
    // Basic game loop
    void Tick();
    void Update(float totalTime, float elapsedTime);
    void Render();

    // Rendering helpers
    void Clear();
    void Present();

	// Command line arguments from View
	static Platform::String^ GetCommandLine();
	static void SetCommandLine(Platform::String^ commandLine);

private:

    void CreateDevice();
    void CreateResources();

    // Core Application state
    Platform::Agile<Windows::UI::Core::CoreWindow>  m_window;
    Windows::Foundation::Rect                       m_windowBounds;

    // Direct3D Objects
    D3D_FEATURE_LEVEL                               m_featureLevel;
    Microsoft::WRL::ComPtr<ID3D11Device1>           m_d3dDevice;
    Microsoft::WRL::ComPtr<ID3D11DeviceContext1>    m_d3dContext;

    // Rendering resources
    Microsoft::WRL::ComPtr<IDXGISwapChain1>         m_swapChain;
    Microsoft::WRL::ComPtr<ID3D11RenderTargetView>  m_renderTargetView;
    Microsoft::WRL::ComPtr<ID3D11DepthStencilView>  m_depthStencilView;
    Microsoft::WRL::ComPtr<ID3D11Texture2D>         m_depthStencil;

    // Game state
    INT64                                           m_frame;
    BasicTimer^                                     m_timer;

private:
	// Command line arguments
	static Platform::String^						CommandLineArguments;
};

// PIX event colors
const DWORD EVT_COLOR_FRAME = PIX_COLOR_INDEX(1);
const DWORD EVT_COLOR_UPDATE = PIX_COLOR_INDEX(2);
const DWORD EVT_COLOR_RENDER = PIX_COLOR_INDEX(3);
